home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 April / CICA MS Windows - April 1993.iso / unzipped / util / enhpcp1 / ftptry.was < prev    next >
Text File  |  1992-12-01  |  5KB  |  142 lines

  1. ;"FtpTry" - Script to auto-login to an ftp site
  2.  
  3. ;You should read it this script through before using it, because there may be a couple
  4. ;of things you need to change (there's at least one that you *must* change).
  5. ;This script is designed to log you in to busy sites, not shut-down ones.  This
  6. ;script assumes that a connection can be established, but that you're getting a
  7. ;"busy signal" of some kind.
  8.  
  9. ;please send any comments, suggestions, complaints, praises, donations (haha) to
  10. ;Erick Hammersmark, ehammers@u.washington.edu
  11.  
  12. string FtpSite,FtpSiteTwo,FtpDir,SiteFile = "c:\prowin\sites.txt"
  13. integer UseDir = 1
  14.  
  15. proc main
  16.    call GetSite                        ;call the site input dialog box
  17.    call ReCall                        ;call the site
  18.    when target 0 "530" call QuitFtp            ;if busy quit and try again
  19.    when target 1 "):" call Login            ;if faced with login prompt, login
  20.    when target 2 "230" call EndFtp            ;if logged in, end script
  21.    while 1
  22.    endwhile
  23. endproc
  24.  
  25. proc ReCall                        ;procedure to call an ftp site
  26.    transmit "ftp "
  27.    transmit Ftpsite
  28.    transmit "^M"
  29. endproc
  30.  
  31. proc QuitFtp                        ;procedure to quit and try again
  32.    transmit "quit^M"                    ;quit
  33.    waitfor "%"                        ;waitfor prompt
  34.    call ReCall                        ;try again
  35. endproc
  36.  
  37. proc EndFtp                        ;procedure to call when logged in
  38.    if Usedir                        ;if "Use working directory" box checked
  39.       waitfor "ftp>"                    ;waitfor prompt
  40.       call GetWorkDir                    ;call procedure to get working directory
  41.       transmit "cd "
  42.       transmit FtpDir
  43.       transmit "^M"                    ;cd to working directory
  44.       waitfor "ftp>"                    ;waitfor prompt
  45.    endif
  46.    alarm 2                        ;if you have a sound card, this line could be changed to:
  47.    exit                            ;mciexec "sound c:\sound\atten.wav", where "c:\sound\atten.wav"
  48. endproc                            ;is the path and filename of your favorite sound.
  49.  
  50.  
  51. proc Login                        ;procedure to login to ftp site
  52.    pause 1                        ;make sure site is ready
  53.    transmit "anonymous^M"
  54.    waitfor "Password:"
  55.    pause 1
  56.    transmit "ehammers@u.washington.edu^M"        ;please change this to your own e-mail address!
  57. endproc
  58.  
  59. proc GetSite                        ;procedure to input ftp site
  60. integer selection = 0
  61. FtpSite = "ftp.cica.indiana.edu"            ;default site - change as desired
  62. call GetWorkDir                        ;call procedure to get working directory from file
  63. UseDir = 1                        ;UseDir check box on by default
  64. dialogbox 109 40 163 102 2 "What site?"
  65.    pushbutton 28 62 40 14 "OK" normal default
  66.    pushbutton 94 62 40 14 "Cancel" cancel
  67.    pushbutton 61 82 40 14 "Manual" normal
  68.    fcombobox 16 11 131 53 SiteFile FtpSite sort
  69.    checkbox 38 28 81 10 "Use Working Directory" UseDir
  70.    vtext 71 44 86 11 left FtpDir
  71.    text  12 44 59 11 left "Working Directory:"
  72. enddialog
  73.    while 1
  74.       selection = $DIALOG
  75.       if selection == 190                ;if fcombobox item is selected
  76.          call GetWorkDir                ;get new working directory
  77.          updatedlg 64                    ;update vtext
  78.       endif
  79.       if selection == 1                    ;if cancel is pressed
  80.          exit
  81.       endif
  82.       if selection == 10                ;if OK is pressed
  83.          exitwhile
  84.       endif
  85.       if selection == 11                ;if Manula is pressed
  86.          call Manually                    ;call procedure to manually enter site
  87.          exitwhile
  88.       endif
  89.    endwhile
  90. endproc
  91.  
  92. proc GetWorkDir                        ;procedure to get working dir from file
  93.    fopen 0 "c:\prowin\sitedirs.txt" READWRITE TEXT    ;open data file
  94.    while 1
  95.       fgets 0 FtpSiteTwo                ;get new site
  96.       fgets 0 FtpDir                    ;get new dir
  97.       strcmp FtpSiteTwo FtpSite
  98.       if success                    ;if new site matches fcombobox selection
  99.          exitwhile                    ;exit loop
  100.       endif
  101.    endwhile
  102.    fclose 0
  103. endproc
  104.  
  105. proc Manually                        ;procedure to manually enter site name, and possibly add it to the list
  106. integer selection = 0
  107. dialogbox 112 35 203 95 2 "Manual Entry"
  108.    editbox 44 12 144 12 FtpSite
  109.    pushbutton 36 50 40 14 "OK" normal
  110.    pushbutton 116 50 40 14 "Cancel" cancel
  111.    pushbutton 76 72 40 14 "Add to List" normal
  112.    text  6 14 30 8 left "FTP Site:"
  113.    editbox 44 30 144 12 FtpDir
  114.    text  3 31 39 10 left "Working Dir:"
  115. enddialog
  116.    while 1
  117.       selection = $DIALOG
  118.       if selection == 10                ;of OK is pressed
  119.          exitwhile
  120.       endif
  121.       if selection == 1                    ;if Cancel is pressed
  122.          exit
  123.       endif
  124.       if selection == 11                ;if Add to List is pressed
  125.          call AddToList                    ;call procedure to add site and working dir to data files
  126.          exitwhile
  127.       endif
  128.    endwhile
  129. endproc
  130.  
  131. proc AddToList                        ;procedure to add site and working dir to data files
  132.    fopen 0 "c:\prowin\sites.txt" READWRITE TEXT        ;site data file
  133.    fseek 0 0 2                        ;go to end of file
  134.    fputs 0 FtpSite                    ;write new site
  135.    fclose 0                        ;close site data file
  136.    fopen 0 "c:\prowin\sitedirs.txt" READWRITE TEXT    ;dir data file
  137.    fseek 0 0 2                        ;go to end of file
  138.    fputs 0 FtpSite                    ;write new site
  139.    fputs 0 FtpDir                    ;write new dir
  140.    fclose 0                        ;close dir data file
  141. endproc
  142.